(ns lastfm-music-recommendation.util
  (:use [clojure.string :only [split]]))

(defn get-songs
  "Extracts songs from search results"
  [search-result]
  (vec (map #(ffirst %) search-result)))

(defn song-to-string
  "Converts [artist song] to string"
  [song]
  (str (first song) " – " (second song)))

(defn string-to-song
  "Converts string to [artist song]"
  [song-str]
  (split song-str #" – "))

(defn split-song
  "Returns all words from song" 
  [song]
  (reduce #(apply merge %1 (split %2 #" ")) 
          [] (string-to-song song)))
